package com.vimi8.ebb.sqlprovider;


import com.vimi8.ebb.model.ElectricityBusiness;
import com.vimi8.ebb.model.ProductInfo;
import com.vimi8.ebb.model.TrainInfo;
import org.apache.ibatis.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * Created by think on 2016/7/7.
 */
public class ElectricityBusinessSqlProvider {
    private Logger logger =  LoggerFactory.getLogger(this.getClass());
    public String getInsertElectricityBusinessTypeSql(Map<String, Object> parameters){
    StringBuilder sqlSb=new StringBuilder();
        List<ElectricityBusiness> electricityBusinessList=  ( List<ElectricityBusiness>)parameters.get("electricityBusinessList");
        sqlSb.append("insert into electricity_business (id,store_name,platform_category_parent,platform_category,store_category_id,type,address_code,address_detail,responsible_person,mobile_no,employee_num,store_url,longitude,latitude,create_time) values");
       int count=0;
        for(ElectricityBusiness electricityBusiness:electricityBusinessList){
            sqlSb.append("('");
            sqlSb.append(electricityBusiness.getId()+"','");
            sqlSb.append(electricityBusiness.getStoreName()+"','");
            sqlSb.append(electricityBusiness.getPlatformCategoryParent()+"','");
            sqlSb.append(electricityBusiness.getPlatformCategory()+"','");
            sqlSb.append(electricityBusiness.getStoreCategoryId()+"','");
            sqlSb.append(electricityBusiness.getType()+"','");
            sqlSb.append(electricityBusiness.getAddressCode()+"','");
            sqlSb.append(electricityBusiness.getAddressDetail()+"','");
            sqlSb.append(electricityBusiness.getResponsiblePerson()+"','");
            sqlSb.append(electricityBusiness.getMobileNo()+"','");
            sqlSb.append(electricityBusiness.getEmployeeNum()+"','");

            sqlSb.append(electricityBusiness.getStoreUrl()+"','");
            sqlSb.append(electricityBusiness.getLongitude()+"','");
            sqlSb.append(electricityBusiness.getLatitude()+"',");
            sqlSb.append("CURRENT_TIMESTAMP()");
            if(electricityBusinessList.size()-1>count){
                sqlSb.append("),");
            }else{
                sqlSb.append(");");
            }

            count++;
        }
        logger.info("sqlStr="+sqlSb.toString());
     return sqlSb.toString();
 }


}
